import {fromJS } from 'immutable'
import * as Type from './types'

const defaultState = fromJS({
  topicList: [],
  articleList: [],
  recommendList: [],
  showScroll: false
})

export default (state = defaultState, action) => {
  console.log('home',action.type)
  switch(action.type){
    case Type.CHANGE_HOME_DATA:
      return state.merge({
        topicList: fromJS(action.topicList),
        articleList: fromJS(action.articleList),
        recommendList: fromJS(action.recommendList)
      })
    case Type.ADD_HOME_LIST:
      console.log(state.get('articleList'))
      console.log(fromJS(action.list))
      return state.set('articleList', state.get('articleList').concat(fromJS(action.list)))
    case Type.TOP_SHOW:
      return state.set('showScroll', action.show)
    default:
      return state
  }
}